import { SearchParamsProps } from "@/components/s-table/type";
import { t } from "@/locales";
import { FormRule, PrimaryTableCol, SelectProps, Tag } from "tdesign-vue-next";

/**
 * 搜索表单项
 */
export const searchParams: SearchParamsProps[] = [
    {
        label: t('pages.sysRole.name'),
        key: 'name',
    },
    {
        label: t('pages.sysRole.code'),
        key: 'code',
    },
];

/**
 * 表格列
 */
export const COLUMNS: PrimaryTableCol[] = [
    //配置表格前面勾选项
    {   colKey: 'row-select', 
        type: 'multiple', 
        width: 50,

    },
    {
        title: t('pages.sysRole.name'),
        ellipsis: true,
        align: 'center',
        colKey: 'name',
    },
    {
        title: t('pages.sysRole.code'),
        ellipsis: true,
        align: 'center',
        colKey: 'code',
    },
    {
        title: t('pages.sysRole.status'),
        ellipsis: true,
        align: 'center',
        colKey: 'status',
        //单独配置状态样式
        cell: (h, { row }) => h(
            Tag,
            { theme: row.status === 0 ? "primary" : "danger" },
            () => t(`components.isSetup.${row.status === 0 ? 'on' : 'off'}`)
        ),
    },
    {
        title: t('pages.sysRole.remarks'),
        ellipsis: true,
        align: 'center',
        colKey: 'remarks',
    },
];

/**
 * 表单校验规则
 */
export const FORM_RULES: Record<string, FormRule[]> = {
    name: [{required: true, message: t('pages.sysRole.required.name'), type: 'error', trigger: 'blur'}],
    code: [{required: true, message: t('pages.sysRole.required.code'), type: 'error', trigger: 'blur'}],
    status: [{ required: true, message: t('pages.sysRole.required.status'), type: 'error', trigger: 'blur' }],
}

/**
 * 配置状态选项
 */
export const statusOptions: SelectProps['options'] =[
    {
        label: t('components.isSetup.on'),
        value: 0,
    },
    {
        label: t('components.isSetup.off'),
        value: 1,
    }
]
    
